package trunk;

import java.util.Scanner;

public class Calculator {
	public Calculator(){
		calculate();
	}
	
	static Scanner in = new Scanner(System.in);
	
	public static int add(int a, int b){
		return a + b;
	}
	
	public static  int subtract(int a, int b){
		return a - b;
	}
	
	public static int multiply(int a, int b){
		return a * b;
	}
	
	public static double divide(int a, int b){
		if( b == 0){
			System.out.println("Cannot divide by zero, dumbass");
			return 1;
		}
		return a / b;		
	}
	
	public static void calculate(){
		
		char a;
		String b, c;
		System.out.println("Input operator and two factors");
		b = in.next();
		while (( a = in.next().charAt(0))!= '@'){
			
			//Get input
			System.out.println("Input operator and two factors");
			
			 c = in.next();
			
			//Parse to ints
			int d = Integer.parseInt(b);
			int e = Integer.parseInt(c);
			
			//Interpret operator
			if (a == '+') {		
				System.out.println (add(d, e));
			}
			if (a == '-') {
				System.out.println(subtract(d, e));
			}
			if(a == '*'){
					System.out.println(multiply(d, e) );
			}
			if (a == '/') {
				System.out.println(divide(d, e));
			}
			b = in.next();
		}
	}
}
